//改变发票内容样式
function contentSelect(o) {
	var mainType = document.getElementById("mainType");
	var labels = mainType.getElementsByTagName("label");
	for (var i = 0; i < labels.length; i++) {
		labels[i].className = "label_style";
	}
	o.getElementsByTagName("label")[0].className = "labelactive";
}
//改变发票类型
function typeSelect(o) {
	var libtns = document.getElementsByClassName("main_piao_btn");
	for (var i = 0; i <= libtns.length - 1; i++) {
		libtns[i].className = "main_piao_btn";
	}
	o.className = "main_piao_btn btn_active";
}

function invoiceSet($scope, $http) {
	//读取原订单信息
	var orders = readData(localStorage.order);
	orders = eval('(' + orders + ')');
	$scope.selected = '无';
	$scope.content = '';
	url = getUrl("27invoiceSet");
	header = getHeader();
	params = 'id=' + readData(localStorage.guideId);
	$http({
		method: 'POST',
		url: url,
		headers: header,
		timeout: 10000,
		//cache: true,
		data: params
	}).success(function(data, status, headers, config) {
		if (data.obj) {
			$scope.types = data.obj.invoiceType;
			$scope.lists = data.obj.list;
		} else {
			$scope.types = null;
			$scope.lists = null;
		};
	}).error(function(data, status, headers, config) {
		console.log("发票页错误")
	});
	$scope.hideCon = true;
	$scope.typeSet = function(type) {
		if (type == "无") {
			$scope.hideCon = true;
		} else {
			$scope.hideCon = false;
		}
		$scope.selected = type;
	}
	$scope.contentSet = function(content) {
			$scope.content = content;
		}
		//确认发票
	$scope.checkIn = function() {
		if ($scope.selected == '无') {
			delete orders['invoice'];
			localStorage.order = writeData(JSON.stringify(orders));
			backOrder();
		} else {
			if (!$scope.head || !$scope.content) {
				mui.toast("请填写发票抬头，选择发票内容")
			} else {
				orders['invoice'] = {
					type: $scope.selected,
					head: $scope.head,
					content: $scope.content
				};
				localStorage.order = writeData(JSON.stringify(orders));
				backOrder();
			}
		}
	}
}
//确认发票后操作
function backOrder() {
	var oper=plus.webview.currentWebview().opener();
	mui.fire(oper,"reload")
	mui.back()
}